#!/usr/bin/env python

# glatex2utf.py
# Copyright (C) 2008 Alexander Rodin                                        
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gtk
from latex2utf import latex2utf

class Latex2UtfWindow (gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("LaTeX 2 UTF")

        vbox = gtk.VBox()
        self.add(vbox)

        hbox = gtk.HBox()
        vbox.add(hbox)

        self.input = gtk.Entry()
        self.input.connect("key-press-event", self.input_key_press)
        hbox.add(self.input)

        self.btn = gtk.Button("_Convert")
        self.btn.connect("clicked", self.convert)
        hbox.pack_end(self.btn, False)

        self.result = gtk.Entry()
        vbox.add(self.result)

        vbox.show_all()

    def input_key_press(self, input, event):
        if event.string == '\r':
            self.convert()

    def convert(self, btn = None):
        self.result.set_text(latex2utf(self.input.get_text()))

w = Latex2UtfWindow()
w.connect("destroy", gtk.main_quit)
w.show_all()
gtk.main()

# vim: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab :

